#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "cwit_notify/cwit_notify.h"

typedef struct __notify_test
{
    int num;
    char a[10];
}notify_test;
void notify_recv_calbak_string(void *param1,void *param2)
{
    printf("notify_recv_calbak_string %s %s \r\n",param1,param2);
}
void notify_recv_calbak_num(void *param1,void *param2)
{
    printf("notify_recv_calbak_num : %d\r\n",param2);
}

void notify_recv_calbak_struct(void *param1,void *param2)
{
    notify_test *userparam = param2;
    notify_test *sendparam = param1;
    printf("notify_recv_calbak_struct num: %d\r\n",userparam->num);
}

int main()
{

    //字符串参数
    cwit_notify_recv(NULL,"noityfy_recv1",strlen("noityfy_recv1"),notify_recv_calbak_string,"userparam");
    cwit_notify_send(NULL,"noityfy_recv1",strlen("noityfy_recv1"),"sendparam");

    //数值参数
    cwit_notify_recv(NULL,"noityfy_recv2",strlen("noityfy_recv2"),notify_recv_calbak_num,((void *)1000));
    cwit_notify_send(NULL,"noityfy_recv2",strlen("noityfy_recv2"),"sss");
    
    int num  = 10;
    cwit_notify_recv(NULL,"noityfy_recv3",strlen("noityfy_recv3"),notify_recv_calbak_num,((void *)num));
    cwit_notify_send(NULL,"noityfy_recv3",strlen("noityfy_recv3"),"sss");

    //结构体参数
    notify_test notify_user,notify_send;
    memset(&notify_user,0,sizeof(notify_user));
    memset(&notify_send,0,sizeof(notify_send));
    notify_user.num = 10;
    memcpy(notify_user.a ,"userparam",strlen("userparam"));
    cwit_notify_recv(NULL,"noityfy_recv_struct",strlen("noityfy_recv_struct"),notify_recv_calbak_struct,&notify_user);
    cwit_notify_send(NULL,"noityfy_recv_struct",strlen("noityfy_recv_struct"),&notify_send);

    //移除回调
    cwit_notify_remove(NULL,"noityfy_recv1",strlen("noityfy_recv1"),notify_recv_calbak_string);
    cwit_notify_send(NULL,"noityfy_recv1",strlen("noityfy_recv1"),"sendparam");
    return 0;
}
